# -*-codeing = utf-8 -*-
# @Tine:2024/9/18 
# @Author:计科201121尚益帆
# File：3.8.py
# @Software:PyCharm
import random

def get_computer_choice():
    """随机生成电脑的选择"""
    choices = ['shitou', 'jiandao', 'bu']
    return random.choice(choices)

def determine_winner(user_choice, computer_choice):
    """判断胜负情况"""
    if user_choice == computer_choice:
        return 0  # 平局
    elif (user_choice == 'shitou' and computer_choice == 'jiandao') or \
            (user_choice == 'jiandao' and computer_choice == 'bu') or \
            (user_choice == 'bu' and computer_choice == 'shitou'):
        return 1  # 用户赢
    else:
        return -1  # 用户输

def play_game():
    coins = 50  # 初始金币
    print("游戏开始，你有50金币。")

    while coins > 0:
        print(f"当前金币数：{coins}")

        # 扣除5个金币
        coins -= 5
        if coins <= 0:
            print("金币不足，游戏结束。你输了！")
            return

            # 用户输入
        user_choice = input("请输入你的选择（shitou(石头)/jiandao(剪刀)[表情](布)）：").strip()

        # 电脑选择
        computer_choice = get_computer_choice()
        print(f"电脑出了：{computer_choice}")

        # 判断胜负
        result = determine_winner(user_choice, computer_choice)

        if result == 1:
            coins += 10
            print("你赢了！金币增加10个。")
        elif result == -1:
            coins -= 5
            print("你输了！金币减少5个。")
        else:
            print("平局，金币不变。")

            # 检查游戏结束条件
        if coins >= 100:
            print("恭喜你！金币达到100，你赢了！")
            return

if __name__ == "__main__":
    play_game()